#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <errno.h>
#include <linux/watchdog.h>
#include <syslog.h>
#include <signal.h>

int main(void)
{
    int fd;
    int wdt_timeout = 5;

    fd = open("/dev/watchdog", O_RDONLY);
    if (fd < 0)
    {
        perror("Can't not open /dev/watchdog");
        return -1;
    }
    ioctl(fd,WDIOC_SETTIMEOUT,&wdt_timeout);

    while(1)
    {
        ioctl(fd, WDIOC_KEEPALIVE, 0);
        sleep(2);
    }

    close(fd);

    return 0;
}
